using UnityEngine;

namespace Voodoo.Distribution
{
	internal static class LocalizationLanguageCode
	{
		internal const string englishLanguageCode = "EN";

		internal const string hebrewLanguageCode = "HE";

		private const string _arabicLanguageCode = "AR";

		private const string _chineseLanguageCode = "ZH-CN";

		private const string _frenchLanguageCode = "FR";

		private const string _germanLanguageCode = "DE";

		private const string _indonesianLanguageCode = "ID";

		private const string _italianLanguageCode = "IT";

		private const string _japaneseLanguageCode = "JA";

		private const string _koreanLanguageCode = "KO";

		private const string _portugueseLanguageCode = "PT";

		private const string _russianLanguageCode = "RU";

		private const string _spanishLanguageCode = "ES";

		private const string _thaiLanguageCode = "TH";

		private const string _chineseSimplifiedLanguageCode = "ZH-CN";

		private const string _chineseTraditionalLanguageCode = "ZH-TW";

		private const string _noRegistryDefaultMessage = "{0} is not defined in the localization registry. Switching to English as default.";

		public static string GetLanguageCode(LocalizationSet set)
		{
			string text = SystemLanguageToLanguageCode();
			if (set.languages.ContainsKey(text))
			{
				return text;
			}
			Debug.LogError($"{text} is not defined in the localization registry. Switching to English as default.");
			return "EN";
		}

		private static string SystemLanguageToLanguageCode()
		{
			return Application.systemLanguage switch
			{
				SystemLanguage.Arabic => "AR", 
				SystemLanguage.Chinese => "ZH-CN", 
				SystemLanguage.French => "FR", 
				SystemLanguage.German => "DE", 
				SystemLanguage.Indonesian => "ID", 
				SystemLanguage.Italian => "IT", 
				SystemLanguage.Japanese => "JA", 
				SystemLanguage.Korean => "KO", 
				SystemLanguage.Hebrew => "HE", 
				SystemLanguage.Portuguese => "PT", 
				SystemLanguage.Russian => "RU", 
				SystemLanguage.Spanish => "ES", 
				SystemLanguage.Thai => "TH", 
				SystemLanguage.ChineseSimplified => "ZH-CN", 
				SystemLanguage.ChineseTraditional => "ZH-TW", 
				_ => "EN", 
			};
		}
	}
}
